/**
 * 
 */
package de.cbf.cam.dsa.facet.armor.editor;

import static de.cbf.util.ui.test_support.ConstantsSWTBOTUtil.DEFAULT_SWT_BOT_KEY;

import org.eclipse.jface.fieldassist.ControlDecoration;
import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;

import de.cbf.cam.dsa.facet.armor.act.ActivatorFacetArmor;
import de.cbf.cam.dsa.facet.armor.test_support.ConstantsSWTBOTArmor;
import de.cbf.util.entity.facet.edit.composites.AbstractCompositeEditFacet;
import de.cbf.util.entity.facet.edit.util.FieldDecoratorUtil;
import de.cbf.util.ui.listener.UiChangeEvent;

/**
 * @author Nebelritter
 *
 */
public class CompositeEditArmor extends AbstractCompositeEditFacet {

	public static final int EVT_EDIT_BE					=  1;
	
	public static final int EVT_EDIT_RS_ALL				=  3;
	
	public static final int EVT_EDIT_RS_HEAD			=  5;
	public static final int EVT_EDIT_RS_CHEST			=  6;
	public static final int EVT_EDIT_RS_BACK			=  7;
	public static final int EVT_EDIT_RS_STOMACH			=  8;
	public static final int EVT_EDIT_RS_ARM_LEFT		=  9;
	public static final int EVT_EDIT_RS_ARM_RIGHT		= 10;
	public static final int EVT_EDIT_RS_LEG_LEFT		= 11;
	public static final int EVT_EDIT_RS_LEG_RIGHT		= 12;
	public static final int EVT_EDIT_ZONE_DIVIDER_RS	= 13;
	public static final int EVT_EDIT_ZONE_DIVIDER_BE	= 14;
	public static final int EVT_EDIT_STARS				= 15;
	
	public static final String TEXT_LABEL_BE 				= "Be: ";
	public static final String TEXT_LABEL_BE_ZONES			= "Be(Hz): ";
	public static final String TEXT_LABEL_RS_ALL 			= "RS All: ";
	public static final String TEXT_LABEL_RS_ALL_ZONES		= "RS All(Hz): ";
	public static final String TEXT_LABEL_RS_HEAD			= "Head: ";
	public static final String TEXT_LABEL_RS_CHEST			= "Chest: ";
	public static final String TEXT_LABEL_RS_BACK			= "Back: ";
	public static final String TEXT_LABEL_RS_STOMACH		= "Stomach: ";
	public static final String TEXT_LABEL_RS_ARM_LEFT		= "Arm(Left): ";
	public static final String TEXT_LABEL_RS_ARM_RIGHT		= "Arm(Right): ";
	public static final String TEXT_LABEL_RS_LEG_LEFT		= "Leg(Left): ";
	public static final String TEXT_LABEL_RS_LEG_RIGHT		= "Leg(Right): ";
	public static final String TEXT_LABEL_ZONE_DIVIDER_RS	= "Zone divider(RS): ";
	public static final String TEXT_LABEL_ZONE_DIVIDER_BE	= "Zone divider(BE): ";;
	public static final String TEXT_LABEL_STARS				= "Stars: ";
	public static final String TEXT_LABEL_CALCULATED_BE 	= "Be(calc): ";

	public static final int RS_WIDTH_HINT = 10;
	public static final int RS_BE_WIDTH_HINT = 30;

	protected Label lbl_BeZones;
	protected Label tx_RsAllZones;
	
	protected Text tx_Be;	
	protected Text tx_RsAll;	
	protected Text tx_RsHead;
	protected Text tx_RsChest;
	protected Text tx_RsBack;
	protected Text tx_RsStomach;
	protected Text tx_RsArmLeft;
	protected Text tx_RsArmRight;
	protected Text tx_RsLegLeft;
	protected Text tx_RsLegRight;
	protected Text tx_ZoneDividerRS;
	protected Text tx_ZoneDividerBE;
	protected Text tx_Stars;
	protected ControlDecoration decoration_Be;
	protected ControlDecoration decoration_RsAll;
	protected ControlDecoration decoration_RsHead;	
	protected ControlDecoration decoration_RsChest;	
	protected ControlDecoration decoration_RsBack;	
	protected ControlDecoration decoration_RsStomach;	
	protected ControlDecoration decoration_RsArmLeft;
	protected ControlDecoration decoration_RsArmRight;	
	protected ControlDecoration decoration_RsLegLeft;	
	protected ControlDecoration decoration_RsLegRight;	
	protected ControlDecoration decoration_ZoneDividerRS;
	protected ControlDecoration decoration_ZoneDividerBE;
	protected ControlDecoration decoration_Stars;

	protected CompositeEditZoneFactors cmp_ZoneFactors;

	
	public CompositeEditArmor(Composite parent, int style, FormToolkit toolkit) {
		super(parent, style, toolkit);			
	}

	/* (non-Javadoc)
	 * @see de.cbf.util.entity.facet.edit.composites.AbstractCompositeEditFacet#createLayout()
	 */
	@Override
	protected GridLayout createLayout() {		
		return new GridLayout(4, false);
	}
	
	/* (non-Javadoc)
	 * @see de.cbf.util.entity.facet.edit.composites.AbstractCompositeEditFacet#createContent(org.eclipse.swt.widgets.Composite)
	 */
	@Override
	protected void createContent(Composite compositeThis) {
		//fRsAll
		Label lb_RsAll = toolkit.createLabel(compositeThis, TEXT_LABEL_RS_ALL,SWT.NONE);
		lb_RsAll.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

		tx_RsAll = toolkit.createText(compositeThis, "",SWT.BORDER);
		tx_RsAll.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
		tx_RsAll.setData(DEFAULT_SWT_BOT_KEY, ConstantsSWTBOTArmor.FACET_ARMOR_TEXT_RS_ALL_ID);
		tx_RsAll.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_RsAll.getText());
				event.setIndex(EVT_EDIT_RS_ALL);
				fireUIChangeEvent(event);
			}
		});
		// Create the decoration for fRsAll
		decoration_RsAll = new ControlDecoration(tx_RsAll,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_RsAll = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_RsAll.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_RsAll.setImage(image_RsAll);
		decoration_RsAll.hide();
		
		//fBe
		Label lb_Be = toolkit.createLabel(compositeThis, TEXT_LABEL_BE,SWT.NONE);
		lb_Be.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

		tx_Be = toolkit.createText(compositeThis, "",SWT.BORDER);
		tx_Be.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
		tx_Be.setData(DEFAULT_SWT_BOT_KEY, ConstantsSWTBOTArmor.FACET_ARMOR_TEXT_BE_ID);
		tx_Be.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_Be.getText());
				event.setIndex(EVT_EDIT_BE);
				fireUIChangeEvent(event);
			}
		});	
		
		// Create the decoration for fBe
		decoration_Be = new ControlDecoration(tx_Be,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_Be = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_Be.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_Be.setImage(image_Be);
		decoration_Be.hide();
		
		//composite for HitZones
		Composite cmp_HitZone = createCompositeHitZones(compositeThis);
		cmp_HitZone.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true,4,1));
	}

	protected Composite createCompositeHitZones(Composite parent) {
		Group cmp_HitZone = new Group(parent, SWT.DOUBLE_BUFFERED);
		cmp_HitZone.setText("Hit Zones..");
		GridLayout glo_HitZone = new GridLayout(2, false);
		glo_HitZone.marginHeight = 0;
		glo_HitZone.marginWidth  = 0;
		cmp_HitZone.setLayout(glo_HitZone);
		
		//Rs Zone Values
		Composite cmp_RSZoneValues = createCompositeRSZoneValues(cmp_HitZone);
		cmp_RSZoneValues.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,1,1));
		// values BE composite 
		Composite cmp_HitZoneBE = createCompositeHitZoneBE(cmp_HitZone);
		cmp_HitZoneBE.setLayoutData(new GridData(SWT.RIGHT,SWT.FILL,true,false,1,1));
		
		cmp_ZoneFactors = new CompositeEditZoneFactors((Composite)cmp_HitZone,SWT.BORDER|SWT.DOUBLE_BUFFERED);
		GridData gd_ZoneFactors = new GridData(SWT.FILL,SWT.FILL,false,false,2,1);
		gd_ZoneFactors.heightHint = 70;
		cmp_ZoneFactors.setLayoutData(gd_ZoneFactors);
		
		return cmp_HitZone;
	}
	
	protected Composite createCompositeRSZoneValues(Composite parent) {	
		
		Composite cmp_RSZoneValues = new Composite(parent, SWT.DOUBLE_BUFFERED);
//		cmp_RSZoneValues.setText("RS Zones..");
		GridLayout glo_RsZoneValues = new GridLayout(8, true);
		glo_RsZoneValues.verticalSpacing = 10;
		glo_RsZoneValues.marginHeight	= 0;
		cmp_RSZoneValues.setLayout(glo_RsZoneValues);
		
		//MAYBE add a picture of zones in background and arrange edit fields accordingly
		String path = "";
		ImageDescriptor imgDesc = ActivatorFacetArmor.getDefault().getImageDescriptor(path);
		Image img_HitZones = imgDesc.createImage(false);
		if(img_HitZones != null){
			cmp_RSZoneValues.setBackgroundImage(img_HitZones);			
		}
				
		// FIRST LINE -> rsHead label
		//fRsHead
		Label placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,3,1));		
		
		Label lb_RsHead = toolkit.createLabel(cmp_RSZoneValues, TEXT_LABEL_RS_HEAD,SWT.BOTTOM);
		lb_RsHead.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false, 2, 1));
		
		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,3,1));

		//SECOND LINE -> rsHead text
		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,3,1));
		
		tx_RsHead = toolkit.createText(cmp_RSZoneValues, "",SWT.BORDER|SWT.CENTER);
		GridData gd_RsHead = new GridData(SWT.FILL,SWT.FILL,false,false,2,1);
		gd_RsHead.widthHint = RS_WIDTH_HINT;
		tx_RsHead.setLayoutData(gd_RsHead);
		tx_RsHead.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_Armor_TEXT_RS_HEAD_ID);
		tx_RsHead.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_RsHead.getText());
				event.setIndex(EVT_EDIT_RS_HEAD);
				fireUIChangeEvent(event);
			}
		});	
				
		// Create the decoration for fRsHead
		decoration_RsHead = new ControlDecoration(tx_RsHead,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_RsHead = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_RsHead.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_RsHead.setImage(image_RsHead);
		decoration_RsHead.hide();
			
		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,3,1));
		
		//THIRD LINE - > rsChest Label,rsBack Label 
		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,2,1));
			
		//fRsChest
		Label lb_RsChest = toolkit.createLabel(cmp_RSZoneValues, TEXT_LABEL_RS_CHEST,SWT.BOTTOM);
		lb_RsChest.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false, 2, 1));
				
		//fRsBack
		Label lb_RsBack = toolkit.createLabel(cmp_RSZoneValues, TEXT_LABEL_RS_BACK,SWT.NONE);
		lb_RsBack.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false, 2, 1));
		
		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,2,1));
		
		//FOURTH LINE ->rsArmRight Label,rsChest Text,rsBack Text,rsArmLeft Label
		//fRsArmRight Label
		Label lb_RsArmRight = toolkit.createLabel(cmp_RSZoneValues, TEXT_LABEL_RS_ARM_RIGHT,SWT.NONE);
		lb_RsArmRight.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false, 2, 1));
		
		//rs Chest text
		tx_RsChest = toolkit.createText(cmp_RSZoneValues, "",SWT.BORDER|SWT.CENTER);
		GridData gd_RsChest = new GridData(SWT.FILL,SWT.FILL,false,false,2,1);
		gd_RsChest.widthHint = RS_WIDTH_HINT;
		tx_RsChest.setLayoutData(gd_RsChest);
		tx_RsChest.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_Armor_TEXT_RS_CHEST_ID);
		tx_RsChest.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_RsChest.getText());
				event.setIndex(EVT_EDIT_RS_CHEST);
				fireUIChangeEvent(event);
			}
		});	
		// Create the decoration for fRSChest
		decoration_RsChest = new ControlDecoration(tx_RsChest,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_RsChest = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_RsChest.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_RsChest.setImage(image_RsChest);
		decoration_RsChest.hide();
		
		//RS Back Text
		tx_RsBack = toolkit.createText(cmp_RSZoneValues, "",SWT.BORDER|SWT.CENTER);
		GridData gd_RsBack = new GridData(SWT.FILL,SWT.FILL,false,false,2,1);
		gd_RsBack.widthHint = RS_WIDTH_HINT;
		tx_RsBack.setLayoutData(gd_RsBack);
		tx_RsBack.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_Armor_TEXT_RS_BACK_ID);
		tx_RsBack.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_RsBack.getText());
				event.setIndex(EVT_EDIT_RS_BACK);
				fireUIChangeEvent(event);
			}
		});	
			
		// Create the decoration for fRsBack
		decoration_RsBack = new ControlDecoration(tx_RsBack,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_RsBack = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_RsBack.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_RsBack.setImage(image_RsBack);
		decoration_RsBack.hide();		
		 //fRsArmLeft label
		Label lb_RsArmLeft = toolkit.createLabel(cmp_RSZoneValues, TEXT_LABEL_RS_ARM_LEFT,SWT.NONE);
		lb_RsArmLeft.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false, 2, 1));
		
		//FITH LINE -> rsArmRight text, rsStomach Label, rsArmLeft Text		
		
		tx_RsArmRight = toolkit.createText(cmp_RSZoneValues, "",SWT.BORDER|SWT.CENTER);
		GridData gd_RsArmRight = new GridData(SWT.FILL,SWT.FILL,false,false,2,1);
		gd_RsArmRight.widthHint = RS_WIDTH_HINT;
		tx_RsArmRight.setLayoutData(gd_RsArmRight);
		tx_RsArmRight.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_Armor_TEXT_RS_ARM_RIGHT_ID);
		tx_RsArmRight.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_RsArmRight.getText());
				event.setIndex(EVT_EDIT_RS_ARM_RIGHT);
				fireUIChangeEvent(event);
			}
		});	
		// Create the decoration for fRsArmRight
		decoration_RsArmRight = new ControlDecoration(tx_RsArmRight,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_RsArmRight = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_RsArmRight.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_RsArmRight.setImage(image_RsArmRight);
		decoration_RsArmRight.hide();

		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,1,1));

		//fRsStomach
		Label lb_RsStomach = toolkit.createLabel(cmp_RSZoneValues, TEXT_LABEL_RS_STOMACH,SWT.NONE);
		lb_RsStomach.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false, 2, 1));

		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,1,1));
		
		tx_RsArmLeft = toolkit.createText(cmp_RSZoneValues, "",SWT.BORDER|SWT.CENTER);
		GridData gd_RsArmLeft = new GridData(SWT.FILL,SWT.FILL,false,false,2,1);
		gd_RsArmLeft.widthHint = RS_WIDTH_HINT;
		tx_RsArmLeft.setLayoutData(gd_RsArmLeft);
		tx_RsArmLeft.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_Armor_TEXT_RS_ARM_LEFT_ID);
		tx_RsArmLeft.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_RsArmLeft.getText());
				event.setIndex(EVT_EDIT_RS_ARM_LEFT);
				fireUIChangeEvent(event);
			}
		});	
		// Create the decoration for fRsArmLeft
		decoration_RsArmLeft = new ControlDecoration(tx_RsArmLeft,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_RsArmLeft = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_RsArmLeft.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_RsArmLeft.setImage(image_RsArmLeft);
		decoration_RsArmLeft.hide();
		
		//SIXTH LINE -> rsStomach Text
		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,3,1));
		
		tx_RsStomach = toolkit.createText(cmp_RSZoneValues, "",SWT.BORDER|SWT.CENTER);
		GridData gd_RsStomach = new GridData(SWT.FILL,SWT.FILL,false,false,2,1);
		gd_RsStomach.widthHint = RS_WIDTH_HINT;
		tx_RsStomach.setLayoutData(gd_RsStomach);
		tx_RsStomach.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_Armor_TEXT_RS_STOMACH_ID);
		tx_RsStomach.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_RsStomach.getText());
				event.setIndex(EVT_EDIT_RS_STOMACH);
				fireUIChangeEvent(event);
			}
		});	
		// Create the decoration for fRsStomach
		decoration_RsStomach = new ControlDecoration(tx_RsStomach,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_RsStomach = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_RsStomach.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_RsStomach.setImage(image_RsStomach);
		decoration_RsStomach.hide();
		
		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,3,1));

		//SEVENTH LINE -> rsLegRight Label, rsLegLeft Label
		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,2,1));
		
		//fRsLegLeft
		Label lb_RsLegLeft = toolkit.createLabel(cmp_RSZoneValues, TEXT_LABEL_RS_LEG_LEFT,SWT.NONE);
		lb_RsLegLeft.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false, 2, 1));
		
		//fRsLegRight
		Label lb_RsLegRight = toolkit.createLabel(cmp_RSZoneValues, TEXT_LABEL_RS_LEG_RIGHT,SWT.NONE);
		lb_RsLegRight.setLayoutData(new GridData(SWT.CENTER, SWT.BOTTOM, false, false, 2, 1));
		
		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,2,1));
		
		//EIGTH LINE -> rsLegLeft Text, rsLegRight Text
		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,2,1));
		
		tx_RsLegLeft = toolkit.createText(cmp_RSZoneValues, "",SWT.BORDER|SWT.CENTER);
		GridData gd_RsLegLeft = new GridData(SWT.FILL,SWT.FILL,false,false,2,1);
		gd_RsLegLeft.widthHint = RS_WIDTH_HINT;
		tx_RsLegLeft.setLayoutData(gd_RsLegLeft);
		tx_RsLegLeft.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_Armor_TEXT_RS_LEG_LEFT_ID);
		tx_RsLegLeft.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_RsLegLeft.getText());
				event.setIndex(EVT_EDIT_RS_LEG_LEFT);
				fireUIChangeEvent(event);
			}
		});	
		// Create the decoration for fRsLegLeft
		decoration_RsLegLeft = new ControlDecoration(tx_RsLegLeft,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_RsLegLeft = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_RsLegLeft.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_RsLegLeft.setImage(image_RsLegLeft);
		decoration_RsLegLeft.hide();
				
		tx_RsLegRight = toolkit.createText(cmp_RSZoneValues, "",SWT.BORDER|SWT.CENTER);
		GridData gd_RsLegRight = new GridData(SWT.FILL,SWT.FILL,false,false,2,1);
		gd_RsLegRight.widthHint = RS_WIDTH_HINT;
		tx_RsLegRight.setLayoutData(gd_RsLegRight);
		tx_RsLegRight.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_Armor_TEXT_RS_LEG_RIGHT_ID);
		tx_RsLegRight.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_RsLegRight.getText());
				event.setIndex(EVT_EDIT_RS_LEG_RIGHT);
				fireUIChangeEvent(event);
			}
		});	
		// Create the decoration for fRsLegRight
		decoration_RsLegRight = new ControlDecoration(tx_RsLegRight,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_RsLegRight = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_RsLegRight.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_RsLegRight.setImage(image_RsLegRight);
		decoration_RsLegRight.hide();
		
		placeHolderLabel = new Label(cmp_RSZoneValues, SWT.NONE);
		placeHolderLabel.setLayoutData(new GridData(SWT.FILL,SWT.FILL,false,false,2,1));
		
		
		
		return cmp_RSZoneValues;
	}

	protected Composite createCompositeHitZoneBE(Group parent) {
		Composite cmp_HitZoneBE = new Composite(parent, SWT.BORDER|SWT.DOUBLE_BUFFERED);
		GridLayout glo_HitZoneBE = new GridLayout(1, false);
		glo_HitZoneBE.verticalSpacing = 4;
		cmp_HitZoneBE.setLayout(glo_HitZoneBE);
		
		//fZoneDividerRS
		Label lb_ZoneDividerRS = toolkit.createLabel(cmp_HitZoneBE, TEXT_LABEL_ZONE_DIVIDER_RS,SWT.NONE);
		lb_ZoneDividerRS.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

		tx_ZoneDividerRS = toolkit.createText(cmp_HitZoneBE, "",SWT.BORDER);
		GridData gd_ZoneDividerRS = new GridData(SWT.FILL,SWT.FILL,false,false,1,1);
		gd_ZoneDividerRS.widthHint = RS_BE_WIDTH_HINT;
		tx_ZoneDividerRS.setLayoutData(gd_ZoneDividerRS);
		tx_ZoneDividerRS.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_Armor_TEXT_ZONE_DIVIDER_RS_ID);
		tx_ZoneDividerRS.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_ZoneDividerRS.getText());
				event.setIndex(EVT_EDIT_ZONE_DIVIDER_RS);
				fireUIChangeEvent(event);
			}
		});	
		// Create the decoration for fZoneDividerRS
		decoration_ZoneDividerRS = new ControlDecoration(tx_ZoneDividerRS,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_ZoneDividerRS = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_ZoneDividerRS.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_ZoneDividerRS.setImage(image_ZoneDividerRS);
		decoration_ZoneDividerRS.hide();
		
		//fRsAllZones
		Label lb_RsAllZones = toolkit.createLabel(cmp_HitZoneBE, TEXT_LABEL_RS_ALL_ZONES,SWT.NONE);
		lb_RsAllZones.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

		tx_RsAllZones = toolkit.createLabel(cmp_HitZoneBE, "",SWT.BORDER);
		tx_RsAllZones.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
		tx_RsAllZones.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_ARMOR_LABEL_RS_ALL_ZONES_ID);		
		
		//fZoneDividerBE
		Label lb_ZoneDividerBE = toolkit.createLabel(cmp_HitZoneBE, TEXT_LABEL_ZONE_DIVIDER_BE,SWT.NONE);
		lb_ZoneDividerBE.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

		tx_ZoneDividerBE = toolkit.createText(cmp_HitZoneBE, "",SWT.BORDER);
		GridData gd_ZoneDividerBE = new GridData(SWT.FILL,SWT.FILL,false,false,1,1);
		gd_ZoneDividerBE.widthHint = RS_BE_WIDTH_HINT;
		tx_ZoneDividerBE.setLayoutData(gd_ZoneDividerBE);
		tx_ZoneDividerBE.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_Armor_TEXT_ZONE_DIVIDER_BE_ID);
		tx_ZoneDividerBE.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_ZoneDividerBE.getText());
				event.setIndex(EVT_EDIT_ZONE_DIVIDER_BE);
				fireUIChangeEvent(event);
			}
		});	
		// Create the decoration for fZoneDividerRS
		decoration_ZoneDividerBE = new ControlDecoration(tx_ZoneDividerBE,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_ZoneDividerBE = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_ZoneDividerBE.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_ZoneDividerBE.setImage(image_ZoneDividerBE);
		decoration_ZoneDividerBE.hide();
		
		//fStars
		Label lb_Stars = toolkit.createLabel(cmp_HitZoneBE, TEXT_LABEL_STARS,SWT.NONE);
		lb_Stars.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

		tx_Stars = toolkit.createText(cmp_HitZoneBE, "",SWT.BORDER);
		GridData gd_Stars = new GridData(SWT.FILL,SWT.FILL,false,false,1,1);
		gd_Stars.widthHint = RS_BE_WIDTH_HINT;
		tx_Stars.setLayoutData(gd_Stars);
		tx_Stars.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_ARMOR_TEXT_STARS_ID);
		tx_Stars.addModifyListener(new ModifyListener() {
			@Override
			public void modifyText(ModifyEvent e) {
				UiChangeEvent event = new UiChangeEvent(CompositeEditArmor.this);
				event.setNewValue(tx_Stars.getText());
				event.setIndex(EVT_EDIT_STARS);
				fireUIChangeEvent(event);
			}
		});	
		// Create the decoration for fStars
		decoration_Stars = new ControlDecoration(tx_Stars,SWT.LEFT|SWT.TOP);
		// Re-use an existing image
		Image image_Stars = FieldDecorationRegistry. getDefault(). getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).
		  getImage();
		// Set description and image
		decoration_Stars.setDescriptionText(FieldDecoratorUtil.TOOLTIP_TEXT_ENTER_NUMBERS_ANY);
		decoration_Stars.setImage(image_Stars);
		decoration_Stars.hide();
		
		//fBeZones
		Label lb_BeZones = toolkit.createLabel(cmp_HitZoneBE, TEXT_LABEL_BE_ZONES,SWT.NONE);
		lb_BeZones.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1));

		lbl_BeZones = toolkit.createLabel(cmp_HitZoneBE, "",SWT.BORDER);
		lbl_BeZones.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
		lbl_BeZones.setData(DEFAULT_SWT_BOT_KEY,ConstantsSWTBOTArmor.FACET_ARMOR_LABEL_BE_ZONES_ID);	
		
		return cmp_HitZoneBE;
	}

	public String getBe() {
		return tx_Be.getText();
	}
	public void setBe(String newBe) {
		if(tx_Be.getText().equals(newBe)){
			return;
		}
		tx_Be.setText(newBe);		
	}

	public String getBeZones() {
		return lbl_BeZones.getText();
	}
	public void setBeZones(String newBeZones) {
		if(lbl_BeZones.getText().equals(newBeZones)){
			return;
		}
		lbl_BeZones.setText(newBeZones);
	}
	
	public String getRsAll() {
		return tx_RsAll.getText();
	}
	public void setRsAll(String newRsAll) {
		if(tx_RsAll.getText().equals(newRsAll)){
			return;
		}
		tx_RsAll.setText(newRsAll);
	}

	public String getRsAllZones() {
		return tx_RsAllZones.getText();
	}
	public void setRsAllZones(String newRsAllZones) {
		if(tx_RsAllZones.getText().equals(newRsAllZones)){
			return;
		}
		tx_RsAllZones.setText(newRsAllZones);
	}

	public String getRsHead() {
		return tx_RsHead.getText();
	}
	public void setRsHead(String newRsHead) {
		if(tx_RsHead.getText().equals(newRsHead)){
			return;
		}
		tx_RsHead.setText(newRsHead);
	}

	public String getRsChest() {
		return tx_RsChest.getText();
	}
	public void setRsChest(String newRsChest) {
		if(tx_RsChest.getText().equals(newRsChest)){
			return;
		}
		tx_RsChest.setText(newRsChest);
	}

	public String getRsBack() {
		return tx_RsBack.getText();
	}
	public void setRsBack(String newRsBack) {
		if(tx_RsBack.getText().equals(newRsBack)){
			return;
		}
		tx_RsBack.setText(newRsBack);
	}

	public String getRsStomach() {
		return tx_RsStomach.getText();
	}
	public void setRsStomach(String newRsStomach) {
		if(tx_RsStomach.getText().equals(newRsStomach)){
			return;
		}
		tx_RsStomach.setText(newRsStomach);
	}

	public String getRsArmLeft() {
		return tx_RsArmLeft.getText();
	}
	public void setRsArmLeft(String newRsArmLeft) {
		if(tx_RsArmLeft.getText().equals(newRsArmLeft)){
			return;
		}
		tx_RsArmLeft.setText(newRsArmLeft);
	}

	public String getRsArmRight() {
		return tx_RsArmRight.getText();
	}
	public void setRsArmRight(String newRsArmRight) {
		if(tx_RsArmRight.getText().equals(newRsArmRight)){
			return;
		}
		tx_RsArmRight.setText(newRsArmRight);
	}

	public String getRsLegLeft() {
		return tx_RsLegLeft.getText();
	}
	public void setRsLegLeft(String newRsLegLeft) {
		if(tx_RsLegLeft.getText().equals(newRsLegLeft)){
			return;
		}
		tx_RsLegLeft.setText(newRsLegLeft);
	}

	public String getRsLegRight() {
		return tx_RsLegRight.getText();
	}
	public void setRsLegRight(String newRsLegRight) {
		if(tx_RsLegRight.getText().equals(newRsLegRight)){
			return;
		}
		tx_RsLegRight.setText(newRsLegRight);
	}
	
	public String getZoneDividerRS() {
		return tx_ZoneDividerRS.getText();
	}
	public void setZoneDividerRS(String newZoneDividerRS) {
		if(tx_ZoneDividerRS.getText().equals(newZoneDividerRS)){
			return;
		}
		tx_ZoneDividerRS.setText(newZoneDividerRS);
	}
	
	public String getZoneDividerBE() {
		return tx_ZoneDividerBE.getText();
	}
	public void setZoneDividerBE(String newZoneDividerBE) {
		if(tx_ZoneDividerBE.getText().equals(newZoneDividerBE)){
			return;
		}
		tx_ZoneDividerBE.setText(newZoneDividerBE);
	}
	
	public String getStars() {
		return tx_Stars.getText();
	}
	public void setStars(String newStars) {
		if(tx_Stars.getText().equals(newStars)){
			return;
		}
		tx_Stars.setText(newStars);
	}
		
	public void setDecorationBeStatus(boolean active) {
		if(active){
			decoration_Be.show();
			tx_Be.setBackground(cl_Text_red);
		}else{
			decoration_Be.hide();
			tx_Be.setBackground(cl_Text_list_bg);
		}	
	}

	public void setDecorationRsAllStatus(boolean active) {
		if(active){
			decoration_RsAll.show();
			tx_RsAll.setBackground(cl_Text_red);
		}else{
			decoration_RsAll.hide();
			tx_RsAll.setBackground(cl_Text_list_bg);
		}	
	}

	public void setDecorationRsHeadStatus(boolean active) {
		if(active){
			decoration_RsHead.show();
			tx_RsHead.setBackground(cl_Text_red);
		}else{
			decoration_RsHead.hide();
			tx_RsHead.setBackground(cl_Text_list_bg);
		}		
	}

	public void setDecorationRsChestStatus(boolean active) {
		if(active){
			decoration_RsChest.show();
			tx_RsChest.setBackground(cl_Text_red);
		}else{
			decoration_RsChest.hide();
			tx_RsChest.setBackground(cl_Text_list_bg);
		}		
	}

	public void setDecorationRsBackStatus(boolean active) {
		if(active){
			decoration_RsBack.show();
			tx_RsBack.setBackground(cl_Text_red);
		}else{
			decoration_RsBack.hide();
			tx_RsBack.setBackground(cl_Text_list_bg);
		}		
	}

	public void setDecorationRsStomachStatus(boolean active) {
		if(active){
			decoration_RsStomach.show();
			tx_RsStomach.setBackground(cl_Text_red);
		}else{
			decoration_RsStomach.hide();
			tx_RsStomach.setBackground(cl_Text_list_bg);
		}		
	}

	public void setDecorationRsArmLeftStatus(boolean active) {
		if(active){
			decoration_RsArmLeft.show();
			tx_RsArmLeft.setBackground(cl_Text_red);
		}else{
			decoration_RsStomach.hide();
			tx_RsArmLeft.setBackground(cl_Text_list_bg);
		}		
	}

	public void setDecorationRsArmRightStatus(boolean active) {
		if(active){
			decoration_RsArmRight.show();
			tx_RsArmRight.setBackground(cl_Text_red);
		}else{
			decoration_RsArmRight.hide();
			tx_RsArmRight.setBackground(cl_Text_list_bg);
		}		
	}

	public void setDecorationRsLegLeftStatus(boolean active) {
		if(active){
			decoration_RsLegLeft.show();
			tx_RsLegLeft.setBackground(cl_Text_red);
		}else{
			decoration_RsLegLeft.hide();
			tx_RsLegLeft.setBackground(cl_Text_list_bg);
		}		
	}

	public void setDecorationRsLegRightStatus(boolean active) {
		if(active){
			decoration_RsLegRight.show();
			tx_RsLegRight.setBackground(cl_Text_red);
		}else{
			decoration_RsLegRight.hide();
			tx_RsLegRight.setBackground(cl_Text_list_bg);
		}		
	}

	public void setDecorationZoneDividerRSStatus(boolean active) {
		if(active){
			decoration_ZoneDividerRS.show();
			tx_ZoneDividerRS.setBackground(cl_Text_red);
		}else{
			decoration_ZoneDividerRS.hide();
			tx_ZoneDividerRS.setBackground(cl_Text_list_bg);
		}		
	}
	
	public void setDecorationZoneDividerBEStatus(boolean active) {
		if(active){
			decoration_ZoneDividerBE.show();
			tx_ZoneDividerBE.setBackground(cl_Text_red);
		}else{
			decoration_ZoneDividerBE.hide();
			tx_ZoneDividerBE.setBackground(cl_Text_list_bg);
		}		
	}

	public void setDecorationStarsStatus(boolean active) {
		if(active){
			decoration_Stars.show();
			tx_Stars.setBackground(cl_Text_red);
		}else{
			decoration_Stars.hide();
			tx_Stars.setBackground(cl_Text_list_bg);
		}		
	}

	/**
	 * @return the cmp_ZoneFactors
	 */
	public CompositeEditZoneFactors getCompositeZoneFactors() {
		return cmp_ZoneFactors;
	}
}
